同源策略:一种浏览器安全机制,默认限制网页脚本跨“源”(协议 + 域名 + 端口)访问资源(如读取另一个网站的响应内容),以降低数据泄露与恶意攻击风险。也常用于解释为什么某些跨站请求“能发出去但读不到返回数据”。(在特定机制如 CORS、postMessage 等下可被安全放宽。)
/ˌseɪm ˈɔːrɪdʒɪn ˈpɒlɪsi/
The same-origin policy stops this page from reading data from another domain.
同源策略会阻止这个页面读取来自另一个域名的数据。
Even though the request is sent, the browser blocks the response because the same-origin policy treats different ports as different origins.
即使请求已经发出,浏览器也会阻止读取响应,因为同源策略把不同端口视为不同的源。
same-origin policy 是由 same(相同的)+ origin(来源/源,指协议、域名与端口的组合)+ policy(策略/规则)构成的计算机安全术语。它在 Web 早期发展中逐渐成为浏览器的核心安全边界之一,用来把不同网站之间的脚本隔离开。